package ejb.casacentral.persistence.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@Entity
@Table
@NamedQueries({
	@NamedQuery(name ="Proveedor.todas",query="select s from Proveedor s "),
	@NamedQuery(name ="Proveedor.porCodigo",query="select s from Proveedor s where s.cuil = :codigo"),
	@NamedQuery(name ="Proveedor.porCodigos",query="select s from Proveedor s where s.cuil in (:codigos)")
})
public class Proveedor implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -1954744564290686015L;
	@Id
	private String cuil;
	@Column
	private String razonSocial;
	@Column
	private String direccion;
	@Column
	private String codigoPostal;
	public Proveedor(String cuil, String razonSocial, String direccion,
			String codigoPostal) {
		super();
		this.cuil = cuil;
		this.razonSocial = razonSocial;
		this.direccion = direccion;
		this.codigoPostal = codigoPostal;
	}
	public Proveedor() {
		super();
	}
	@Override
	public String toString() {
		return "Proveedor [cuil=" + cuil + ", razonSocial=" + razonSocial
				+ ", direccion=" + direccion + ", codigoPostal=" + codigoPostal
				+ "]";
	}
	public String getCuil() {
		return cuil;
	}
	public void setCuil(String cuil) {
		this.cuil = cuil;
	}
	public String getRazonSocial() {
		return razonSocial;
	}
	public void setRazonSocial(String razonSocial) {
		this.razonSocial = razonSocial;
	}
	public String getDireccion() {
		return direccion;
	}
	public void setDireccion(String direccion) {
		this.direccion = direccion;
	}
	public String getCodigoPostal() {
		return codigoPostal;
	}
	public void setCodigoPostal(String codigoPostal) {
		this.codigoPostal = codigoPostal;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((codigoPostal == null) ? 0 : codigoPostal.hashCode());
		result = prime * result + ((cuil == null) ? 0 : cuil.hashCode());
		result = prime * result
				+ ((direccion == null) ? 0 : direccion.hashCode());
		result = prime * result
				+ ((razonSocial == null) ? 0 : razonSocial.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Proveedor other = (Proveedor) obj;
		if (codigoPostal == null) {
			if (other.codigoPostal != null)
				return false;
		} else if (!codigoPostal.equals(other.codigoPostal))
			return false;
		if (cuil == null) {
			if (other.cuil != null)
				return false;
		} else if (!cuil.equals(other.cuil))
			return false;
		if (direccion == null) {
			if (other.direccion != null)
				return false;
		} else if (!direccion.equals(other.direccion))
			return false;
		if (razonSocial == null) {
			if (other.razonSocial != null)
				return false;
		} else if (!razonSocial.equals(other.razonSocial))
			return false;
		return true;
	}
	
	


}
